What is @microsoft/applicationinsights-web?
@microsoft/applicationinsights-web is a JavaScript library that provides a way to collect and send telemetry data from web applications to Azure Application Insights. It helps in monitoring the performance, usage, and errors of web applications.
What are @microsoft/applicationinsights-web's main functionalities?
Basic Setup
This code initializes the Application Insights instance with the provided instrumentation key and tracks a page view.
const { ApplicationInsights } = require('@microsoft/applicationinsights-web');
const appInsights = new ApplicationInsights({ config: {
instrumentationKey: 'YOUR_INSTRUMENTATION_KEY'
} });
appInsights.loadAppInsights();
appInsights.trackPageView();
Custom Event Tracking
This code tracks a custom event with a name and additional properties.
appInsights.trackEvent({ name: 'myCustomEvent', properties: { customProperty: 'customValue' } });
Exception Tracking
This code tracks an exception that occurs within the application.
try {
throw new Error('Test error');
} catch (e) {
appInsights.trackException({ exception: e });
}
Dependency Tracking
This code tracks a dependency call, such as an HTTP request, with details like duration, success status, and result code.
appInsights.trackDependencyData({
id: 'uniqueId',
target: 'http://example.com',
name: 'GET /example',
duration: 300,
success: true,
resultCode: 200
});
User and Session Tracking
This code sets the authenticated user context, which helps in tracking user and session data.
appInsights.setAuthenticatedUserContext('userId', 'accountId');
Other packages similar to @microsoft/applicationinsights-web
google-analytics
Google Analytics is a widely used web analytics service that tracks and reports website traffic. It offers similar functionalities like event tracking, user tracking, and performance monitoring. However, it is more focused on marketing analytics compared to the broader application performance monitoring provided by Application Insights.
mixpanel
Mixpanel is an advanced analytics platform that focuses on tracking user interactions with web and mobile applications. It offers features like event tracking, user segmentation, and funnel analysis. Mixpanel is more user-centric and provides deeper insights into user behavior compared to Application Insights.
sentry
Sentry is an open-source error tracking tool that helps developers monitor and fix crashes in real-time. It provides detailed error reports, performance monitoring, and release tracking. Sentry is more focused on error and performance monitoring, whereas Application Insights offers a broader range of telemetry data.
Microsoft Application Insights JavaScript SDK - Web
Application Insights SDK is a package that combines commonly used packages for Web scenarios.
Refer to our GitHub page for more details on getting started.
V3.x Release Breaking changes
- Removed ES3 / IE8 Support
- Removed V1 API Backward Compatibility (Upgrading V1 -> V3)
See Breaking Changes
CDN Version Release Summary (with Size tracking)
Version | Full Size | Raw Minified | GZip Size |
---|
<nightly3> | | | |
3.3.4: | | | |
3.3.3: | | | |
3.3.2: | | | |
3.3.1: | | | |
3.3.0: | | | |
3.2.2: | | | |
3.2.1: | | | |
3.2.0: | | | |
3.1.2: | | | |
3.1.1: | | | |
3.1.0: | | | |
3.0.9: | | | |
3.0.8: | | | |
3.0.7: | | | |
3.0.6: | | | |
3.0.5: | | | |
3.0.4: | | | |
3.0.3: | | | |
3.0.2: | | | |
3.0.1: | | | |
3.0.0: | | | |
| | | |
2.8.18: | | | |
2.8.17: | | | |
2.8.16: | | | |
2.8.15: | | | |
2.8.14: | | | |
2.8.13: | | | |
2.8.12: | | | |
2.8.11: | | | |
2.8.10: | | | |
2.8.9: | | | |
2.8.8: | | | |
2.8.7: | | | |
2.8.6: | | | |
2.8.5: | | | |
2.8.4: | | | |
2.8.3: | | | |
2.8.2: | | | |
2.8.1: | | | |
2.8.0: | | | |
2.7.4: | | | |
2.7.3: | | | |
2.7.2: | | | |
2.7.1: | | | |
2.7.0: | | | |
2.6.5: | | | |
2.6.4: | | | |
2.6.3: | | | |
2.6.2: | | | |
2.6.1: | | | |
2.6.0: | | | |
2.5.11: | | | |
2.5.10: | | | |
2.5.9: | | | |
2.5.8: | | | |
2.5.7: | | | |
2.5.6: | | | |
2.5.5: | | | |
2.5.4: | | | |
2.5.3: | | | |
2.5.2: | | | |
2.5.0 - 2.5.1 | Not Deployed to CDN | | |
2.4.4: | | | |
2.4.3: | | | |
2.4.2: | Not Deployed to CDN | | |
2.4.1: | | | |
2.4.0: | Not Deployed to CDN | | |
2.3.1: | | | |
2.3.0: | | | |
2.2.2: | | | |
2.2.1: | Not Deployed to CDN | | |
2.2.0: | | | |
2.1.0: | | | |
2.0.1: | | | |
2.0.0: | | | |
Contributing
This project welcomes contributions and suggestions. Most contributions require you to
agree to a Contributor License Agreement (CLA) declaring that you have the right to,
and actually do, grant us the rights to use your contribution. For details, visit
https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need
to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the
instructions provided by the bot. You will only need to do this once across all repositories using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct.
For more information see the Code of Conduct FAQ
or contact opencode@microsoft.com with any additional questions or comments.
Data Collection
As this SDK is designed to enable applications to perform data collection which is sent to the Microsoft collection endpoints the following is required to identify our privacy statement.
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft’s Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.
License
MIT